"""
    tqdm是Python中专门用于进度条美化的模块，通过在非while的循环体内嵌入tqdm，可以得到一个能更好展现程序运行过程的提示进度条
"""
from tqdm import tqdm
from tqdm import trange

import time


def func1():
    """在for循环体中用 tqdm() 包裹指定的迭代器"""
    text = ""
    for char in tqdm(["a", "b", "c", "d"]):
        time.sleep(0.25)
        text = text + char

    print(text)


def func2():
    """在 for 循环体中用 tqdm() 包裹 range()"""
    for it in tqdm(range(10)):
        time.sleep(0.5)


def func3():
    for i in trange(100):
        time.sleep(0.01)


def func4():
    with tqdm(total=100) as pbar:
        for i in range(10):
            time.sleep(0.1)
            pbar.update(10)


def func5():
    pbar = tqdm(total=100)
    for i in range(100):
        time.sleep(0.1)
        pbar.update(1)
    pbar.close()


if __name__ == '__main__':
    func5()
